#include "plan_operator_widget.h"
#include "ui_plan_operator_widget.h"
#include <QFile>

PlanOperatorWidget::PlanOperatorWidget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::PlanOperatorWidget)
{
    ui->setupUi(this);
    initUi();
    initEvents();
}

PlanOperatorWidget::~PlanOperatorWidget()
{
    delete ui;
}

void PlanOperatorWidget::initUi()
{
#ifdef Q_OS_ANDROID
    QFile styleFile(":/resources/qss/plan_operator_widget_android.qss");
    styleFile.open(QIODevice::ReadOnly);
    QString stylesheet = styleFile.readAll();
    styleFile.close();
#else
    QFile styleFile(":/resources/qss/plan_operator_widget.qss");
    styleFile.open(QIODevice::ReadOnly);
    QString stylesheet = styleFile.readAll();
    styleFile.close();
#endif
    setStyleSheet(stylesheet);
}

void PlanOperatorWidget::initEvents()
{
    connect(ui->btnAddNew, &QPushButton::clicked, this, [=]() {
        emit(addNewTriggered());
    });
}
